
Ext.define('ModeloUsuarios', {
    extend: 'Ext.data.Model',
    fields: [{
        name: 'id',
        type: 'int',
        //useNull: true
    },{
        name: 'nroDocumento',
        type: 'int',
    },{
        name: 'telefono',
        type: 'int',
    }, 'email', 'nombre', 'apellido', 'nombreUsuario', 'fecha'],
    validations: [{
        type: 'length',
        field: 'email',
        min: 1
    }, {
        type: 'length',
        field: 'first',
        min: 1
    }, {
        type: 'length',
        field: 'last',
        min: 1
    }, {
        type: 'length',
        field: 'nombreUsuario',
        min: 1
    }]
});

//Ext.Loader.setConfig({enabled: true});
//Ext.Loader.setPath('Ext.ux', 'static/ux');

Ext.define('proyectos.DesarrolladoresGrid', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.DesarrolladoresGrid',

    requires: [
        'Ext.form.field.Text',
        //'Ext.ux.grid.FiltersFeature',
        'Ext.toolbar.TextItem'
    ],

    initComponent: function(){
      
        /*var filters = {
			ftype: 'filters',
			local: true,

		};*/

        Ext.apply(this, {
            iconCls: 'icon-grid',
            //features: [filters],
            dockedItems: [{ 
                weight: 1,
                xtype: 'toolbar',
                dock: 'bottom',
                items: ['->', {
                    iconCls: 'icon-refresh',
                    text: '<b>Actualizar</b>',
                    tooltip:'Actualizar la lista',
                    scope: this,
                    handler: this.onRefresh
                },{
                    iconCls: 'icon-salir',
                    text: '<b>Salir</b>',
                    scope: this,
                    handler: this.onSalir
                }]
            }],
            columns: [{
                text: 'Id',
                width: 40,
                hidden: true,
                //filter: true,
                dataIndex: 'id'
            },{
                header: '<b>Usuario</b>',
                flex: 1,
                //width: 90,
                //filter: true,
                dataIndex: 'nombreUsuario',

            },{
                header: '<b>Nombre</b>',
                flex: 1,
                //filter: true,
                dataIndex: 'nombre',

            }, {
                header: '<b>Apellido</b>',
                flex: 1,
                //filter: true,
                dataIndex: 'apellido',

            },{
                text: '<b>Telefono</b>',
                width: 75,
                //filter: true,              
                dataIndex: 'telefono'
            },{
                text: '<b>Nº CI</b>',
                width: 75,
                //filter: true,
                dataIndex: 'nroDocumento'
            }, {
                header: '<b>Email</b>',
                width: 150,
                //filter: true,
                dataIndex: 'email',

            },{
                header: '<b>Fecha Creacion</b>',
                width: 100,
                hidden: true,
                //filter: true,
                dataIndex: 'fecha',

            }]
        });
        this.callParent();
        this.getSelectionModel().on('selectionchange', this.onSelectChange, this);
    },
    
    onListar: function(){
		this.fireEvent('listarTodo');
		/*this.getSelectionModel().clearSelections();
		this.store.load();*/
    },
    
	onSalir: function(){
		 
		this.fireEvent('salir');
	},

    onRefresh: function(){
		this.getSelectionModel().clearSelections();
		this.store.load();
    }
});
